package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-03-01 00:03
 */
public class IsMonotonic {
    public boolean isMonotonic(int[] A) {

        return incremental(A)||decrease(A);
    }

    Boolean incremental(int[] A) {
        if (A.length == 1) return true;
        for (int i = 0; i < A.length - 1; i++) {
            if ( A[i] > A[i + 1]){
                return false;
            }

        }
        return true;
    }

    Boolean decrease(int[] A){
        if (A.length == 1) return true;
        for (int i = 0; i < A.length - 1; i++) {
            if ( A[i] <A[i + 1]){
                return false;
            }

        }
        return true;
    }
}
